package br.uefs.ecomp.myBook.view;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.*;

import br.uefs.ecomp.myBook.model.GeneralFile;
import br.uefs.ecomp.myBook.model.GeneralUpload;
import br.uefs.ecomp.myBook.model.MyBookVisibility;

public class FilePanelTest extends JFrame implements ActionListener{
	
	private FilePanelTest() throws IOException{
		GeneralFile f1, f2, f3, f4;
		
		f1 = GeneralFile.parse("mybook/files/penguins.jpg");
		f2 = GeneralFile.parse("mybook/files/texticulo.txt");
		f3 = GeneralFile.parse("mybook/files/sample.mp3");
		f4 = GeneralFile.parse("mybook/files/nullvideo.avi");
		
		MyBookVisibility vis = MyBookVisibility.FRIENDS_ONLY;
		
		JPanel internalPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
		
		this.setContentPane(internalPanel);
		
		internalPanel.add(new FilePanel(new GeneralUpload(f1, "Penguins",vis), this));
		internalPanel.add(new FilePanel(new GeneralUpload(f2, "Little Text",vis), this));
		internalPanel.add(new FilePanel(new GeneralUpload(f3, "Audio mp3",vis), this));
		internalPanel.add(new FilePanel(new GeneralUpload(f4, "VideoFile",vis), this));
		
		
	}
	
	public static void main(String[] args) throws IOException{
		FilePanelTest window = new FilePanelTest();
		window.setVisible(true);
		window.revalidate();
		window.repaint();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		JOptionPane.showMessageDialog(this, "Apertado: "+((GeneralUpload)e.getSource()).getFile().getFileName());
	}
	
}
